package com.example.service.impl;

import com.example.datasource.DataSource;
import com.example.datasource.DataSourceNames;
import com.example.entity.Student;
import com.example.mapper.StudentMapper;
import com.example.service.StudentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author sgf-success
 * @since 2019-04-15
 */
@Service
public class StudentServiceImpl extends ServiceImpl<StudentMapper, Student> implements StudentService {

    /**
     * 默认使用的是defaultDataSource
     * @param id
     * @return
     */
    @Override
    public Student findStudentByFirstDb(long id) {
        return this.baseMapper.selectById(id);
    }

    @DataSource(name = DataSourceNames.SECOND)
    @Override
    public Student findStudentBySecondDb(long id) {
        return this.baseMapper.selectById(id);
    }
}
